﻿
namespace BuildARouteApp.Web.Services
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;
    using BuildARouteApp.Web.Models;


    // Implements application logic using the Entities context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public class TourGuideDomainService : LinqToEntitiesDomainService<Entities>
    {

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Languages' query.
        [Query(IsDefault = true)]
        public IQueryable<Language> GetLanguages()
        {
            return this.ObjectContext.Languages;
        }

        public void InsertLanguage(Language language)
        {
            if ((language.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(language, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Languages.AddObject(language);
            }
        }

        public void UpdateLanguage(Language currentLanguage)
        {
            this.ObjectContext.Languages.AttachAsModified(currentLanguage, this.ChangeSet.GetOriginal(currentLanguage));
        }

        public void DeleteLanguage(Language language)
        {
            if ((language.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Languages.Attach(language);
            }
            this.ObjectContext.Languages.DeleteObject(language);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'POIs' query.
        [Query(IsDefault = true)]
        public IQueryable<POI> GetPOIs()
        {
            return this.ObjectContext.POIs;
        }

        public void InsertPOI(POI pOI)
        {
            if ((pOI.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(pOI, EntityState.Added);
            }
            else
            {
                this.ObjectContext.POIs.AddObject(pOI);
            }
        }

        public void UpdatePOI(POI currentPOI)
        {
            this.ObjectContext.POIs.AttachAsModified(currentPOI, this.ChangeSet.GetOriginal(currentPOI));
        }

        public void DeletePOI(POI pOI)
        {
            if ((pOI.EntityState == EntityState.Detached))
            {
                this.ObjectContext.POIs.Attach(pOI);
            }
            this.ObjectContext.POIs.DeleteObject(pOI);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'SocialInputs' query.
        [Query(IsDefault = true)]
        public IQueryable<SocialInput> GetSocialInputs()
        {
            return this.ObjectContext.SocialInputs;
        }

        public void InsertSocialInput(SocialInput socialInput)
        {
            if ((socialInput.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(socialInput, EntityState.Added);
            }
            else
            {
                this.ObjectContext.SocialInputs.AddObject(socialInput);
            }
        }

        public void UpdateSocialInput(SocialInput currentSocialInput)
        {
            this.ObjectContext.SocialInputs.AttachAsModified(currentSocialInput, this.ChangeSet.GetOriginal(currentSocialInput));
        }

        public void DeleteSocialInput(SocialInput socialInput)
        {
            if ((socialInput.EntityState == EntityState.Detached))
            {
                this.ObjectContext.SocialInputs.Attach(socialInput);
            }
            this.ObjectContext.SocialInputs.DeleteObject(socialInput);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Stops' query.
        [Query(IsDefault = true)]
        public IQueryable<Stop> GetStops()
        {
            return this.ObjectContext.Stops;
        }

        public void InsertStop(Stop stop)
        {
            if ((stop.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(stop, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Stops.AddObject(stop);
            }
        }

        public void UpdateStop(Stop currentStop)
        {
            this.ObjectContext.Stops.AttachAsModified(currentStop, this.ChangeSet.GetOriginal(currentStop));
        }

        public void DeleteStop(Stop stop)
        {
            if ((stop.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Stops.Attach(stop);
            }
            this.ObjectContext.Stops.DeleteObject(stop);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'StopPOIs' query.
        [Query(IsDefault = true)]
        public IQueryable<StopPOI> GetStopPOIs()
        {
            return this.ObjectContext.StopPOIs;
        }

        public void InsertStopPOI(StopPOI stopPOI)
        {
            if ((stopPOI.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(stopPOI, EntityState.Added);
            }
            else
            {
                this.ObjectContext.StopPOIs.AddObject(stopPOI);
            }
        }

        public void UpdateStopPOI(StopPOI currentStopPOI)
        {
            this.ObjectContext.StopPOIs.AttachAsModified(currentStopPOI, this.ChangeSet.GetOriginal(currentStopPOI));
        }

        public void DeleteStopPOI(StopPOI stopPOI)
        {
            if ((stopPOI.EntityState == EntityState.Detached))
            {
                this.ObjectContext.StopPOIs.Attach(stopPOI);
            }
            this.ObjectContext.StopPOIs.DeleteObject(stopPOI);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'sysdiagrams' query.
        [Query(IsDefault = true)]
        public IQueryable<sysdiagram> GetSysdiagrams()
        {
            return this.ObjectContext.sysdiagrams;
        }

        public void InsertSysdiagram(sysdiagram sysdiagram)
        {
            if ((sysdiagram.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(sysdiagram, EntityState.Added);
            }
            else
            {
                this.ObjectContext.sysdiagrams.AddObject(sysdiagram);
            }
        }

        public void UpdateSysdiagram(sysdiagram currentsysdiagram)
        {
            this.ObjectContext.sysdiagrams.AttachAsModified(currentsysdiagram, this.ChangeSet.GetOriginal(currentsysdiagram));
        }

        public void DeleteSysdiagram(sysdiagram sysdiagram)
        {
            if ((sysdiagram.EntityState == EntityState.Detached))
            {
                this.ObjectContext.sysdiagrams.Attach(sysdiagram);
            }
            this.ObjectContext.sysdiagrams.DeleteObject(sysdiagram);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Tags' query.
        [Query(IsDefault = true)]
        public IQueryable<Tag> GetTags()
        {
            return this.ObjectContext.Tags;
        }

        public void InsertTag(Tag tag)
        {
            if ((tag.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(tag, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Tags.AddObject(tag);
            }
        }

        public void UpdateTag(Tag currentTag)
        {
            this.ObjectContext.Tags.AttachAsModified(currentTag, this.ChangeSet.GetOriginal(currentTag));
        }

        public void DeleteTag(Tag tag)
        {
            if ((tag.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Tags.Attach(tag);
            }
            this.ObjectContext.Tags.DeleteObject(tag);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Tours' query.
        [Query(IsDefault = true)]
        public IQueryable<Tour> GetTours()
        {
            return this.ObjectContext.Tours;
        }

        public void InsertTour(Tour tour)
        {
            if ((tour.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(tour, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Tours.AddObject(tour);
            }
        }

        public void UpdateTour(Tour currentTour)
        {
            this.ObjectContext.Tours.AttachAsModified(currentTour, this.ChangeSet.GetOriginal(currentTour));
        }

        public void DeleteTour(Tour tour)
        {
            if ((tour.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Tours.Attach(tour);
            }
            this.ObjectContext.Tours.DeleteObject(tour);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Translations' query.
        [Query(IsDefault = true)]
        public IQueryable<Translation> GetTranslations()
        {
            return this.ObjectContext.Translations;
        }

        public void InsertTranslation(Translation translation)
        {
            if ((translation.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(translation, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Translations.AddObject(translation);
            }
        }

        public void UpdateTranslation(Translation currentTranslation)
        {
            this.ObjectContext.Translations.AttachAsModified(currentTranslation, this.ChangeSet.GetOriginal(currentTranslation));
        }

        public void DeleteTranslation(Translation translation)
        {
            if ((translation.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Translations.Attach(translation);
            }
            this.ObjectContext.Translations.DeleteObject(translation);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Users' query.
        [Query(IsDefault = true)]
        public IQueryable<User> GetUsers()
        {
            return this.ObjectContext.Users;
        }

        public void InsertUser(User user)
        {
            if ((user.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(user, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Users.AddObject(user);
            }
        }

        public void UpdateUser(User currentUser)
        {
            this.ObjectContext.Users.AttachAsModified(currentUser, this.ChangeSet.GetOriginal(currentUser));
        }

        public void DeleteUser(User user)
        {
            if ((user.EntityState == EntityState.Detached))
            {
                this.ObjectContext.Users.Attach(user);
            }
            this.ObjectContext.Users.DeleteObject(user);
        }

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'UserVisiteds' query.
        [Query(IsDefault = true)]
        public IQueryable<UserVisited> GetUserVisiteds()
        {
            return this.ObjectContext.UserVisiteds;
        }

        public void InsertUserVisited(UserVisited userVisited)
        {
            if ((userVisited.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(userVisited, EntityState.Added);
            }
            else
            {
                this.ObjectContext.UserVisiteds.AddObject(userVisited);
            }
        }

        public void UpdateUserVisited(UserVisited currentUserVisited)
        {
            this.ObjectContext.UserVisiteds.AttachAsModified(currentUserVisited, this.ChangeSet.GetOriginal(currentUserVisited));
        }

        public void DeleteUserVisited(UserVisited userVisited)
        {
            if ((userVisited.EntityState == EntityState.Detached))
            {
                this.ObjectContext.UserVisiteds.Attach(userVisited);
            }
            this.ObjectContext.UserVisiteds.DeleteObject(userVisited);
        }
    }
}


